#ifndef METHODINFO_H
#define METHODINFO_H

#include <vector>
#include <stdio.h>
#include "AttributeInfo.h"

#include "jtypes.h"

class ConstantPool;

class MethodInfo 
{
  public:
  MethodInfo(ConstantPool * cp, FILE *f);

  MethodInfo(ConstantPool * cp, const char * name, 
    const char * signature, u2 access_flags);

  void dump();

  void save(FILE *f);

  const char * getName();
  const char * getSignature();

  void         assemble(u1 opcode);
  void         assemble(u1 opcode, u4 operand);
  inline u4    getAP() { return code->getAP(); };
  inline void  assembleAt(u4 offset,u1 opcode, u4 operand) { code->assembleAt(offset,opcode,operand); }
  inline void  relocAt(u4 offset, u4 operand) { code->relocAt(offset,operand); }

  /* editing code */
  void         resetCode();
  void         assemblePrintStringStatement(const char * string);

  private:
  u2 access_flags;
  u2 name_index;
  u2 signature_index;
  std::vector<AttributeInfo*> attributes;

  AttributeInfoCode * code;

  ConstantPool * constantPool;
};


#endif
